package pendotech.com.pendootg.mvp;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import pendotech.com.pendootg.R;
import pendotech.com.pendootg.bean.Account;

public class MvpActivity extends AppCompatActivity implements View.OnClickListener ,ImvpView{

    private EditText input_et;
    private Button search_btn;
    private TextView result_tv;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        input_et = findViewById(R.id.input_et);
        search_btn = findViewById(R.id.search_btn);
        result_tv = findViewById(R.id.result_tv);

        search_btn.setOnClickListener(this);

        mvpPresent=new MvpPresent(this);

    }

    private  MvpPresent mvpPresent;

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.search_btn:
                mvpPresent.getData(getInputContent());
                break;
        }
    }

    @Override
    public void showSuccessMsg(Account account) {
        result_tv.setText(account.getName() + "--年龄：" + account.getAge());
    }

    @Override
    public String getInputContent() {
        return input_et.getText().toString();

    }

    @Override
    public void showFailMsg() {
        result_tv.setText("查无此人~");
    }
}